﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BCDto.Common.News.ContentCategory;
using BCService.Common.News.ContentCategory;
using Microsoft.AspNetCore.Mvc;

// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace BCTMSRESTful.Controllers.Anonymous
{
    /// <summary>
    /// 内容分类控制器
    /// </summary>
    [Route("api/v1/[controller]")]
    [ApiController]
    public class ContentCategoriesController : BCTMSRESTfulAPIController
    {
        private readonly IContentCategoryService contentCategoryService;
        /// <summary>
        /// 内容分类控制器
        /// </summary>
        public ContentCategoriesController(IContentCategoryService contentCategoryService)
        {
            this.contentCategoryService = contentCategoryService;
        }
        /// <summary>
        /// 获取某一内容分类信息
        /// </summary>
        /// <param name="contentCategoryId">内容分类ID</param>
        /// <returns></returns>
        [HttpGet("{content_category_id}")]
        [ProducesResponseType(typeof(ContentCategoryDto), 200)]
        public IActionResult Get([FromRoute(Name = "content_category_id")]int contentCategoryId)
        {
            return this.Ok(this.contentCategoryService.GetContentCategoryById(contentCategoryId));
        }
        /// <summary>
        /// 获取一级分类列表
        /// </summary>
        /// <param name="level">分类级别</param>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(IEnumerable<ContentCategoryDto>), 200)]
        public IActionResult LevelCategory([FromQuery(Name = "level")]int level = 1)
        {
            return this.Ok(this.contentCategoryService.GetLevelCategoryList(level));
        }

        /// <summary>
        /// 根据分类ID获取下级分类
        /// </summary>
        /// <param name="contentCategoryId">内容分类Id</param>
        /// <returns></returns>
        [HttpGet("NextCategory/{content_category_id}")]
        [ProducesResponseType(typeof(ContentCategoryDto), 200)]
        public IActionResult GetNextCategoryByID([FromRoute(Name = "content_category_id")]int contentCategoryId)
        {
            return this.Ok(this.contentCategoryService.GetNextCategoryById(contentCategoryId));
        }
    }
}
